#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include "lex.yy.c"
#include "y.tab.h"
#include "operation.h"

extern DatabaseConfigStructPoint m_databaseConfig;

void yyerror(char * error){
    fprintf(stderr, "error: %s\n",error);
}


int main(int argc,char *argv[]){

    m_databaseConfig = (DatabaseConfigStructPoint)malloc(sizeof(DatabaseConfigStruct));
    m_databaseConfig->m_dataPath = NULL;
    m_databaseConfig->tabLength = 0;

    if(argc >= 3){
        
        int index = 1;
        while(index+1 < argc){
            if(!strcmp("-c",argv[index])){
                m_databaseConfig->configPath = argv[index+1];
                break;
            }
            index += 2;
        }

    }
    m_databaseConfig->configPath = "../config/LiSQL.conf";

    printf("Init database...\n");

    initDatabase();

    printf("LiSQL>");

    return yyparse();
}
